<%@page import="Modelo.Querys"%>
<%@page import="Modelo.Selects"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <jsp:include page="head.jsp"></jsp:include>
    <body>
        <script type="text/javascript">
            $(document).ready(function(){
            <%=Querys.CheckDB()%>
            <%
            String mensaje = request.getParameter("FinalMessage");
            String tipo = request.getParameter("TypeMessage");
            if (mensaje != null) {
            %>
                
                //alert('');
                new Messi('<%=mensaje%>', {title: 'Resultado', autoclose: '4000', titleClass: '<%= tipo%> anim', buttons: [{id: 0, label: 'Cerrar', val: 'X'}]});
                
            <%
            }
            %>
                var VulnerabilitySelected = $("#SelectVulnerability option:selected").val();
                $("#Resultado").load("Contr_avi.jsp?Type=1&Vulnerability="+VulnerabilitySelected);
                $("#SelectVulnerability").change(function(){
                    var VulnerabilitySelected = $("#SelectVulnerability option:selected").val();
                    $("#Resultado").load("Contr_avi.jsp?Type=1&Vulnerability="+VulnerabilitySelected);
                });
                
    $("#Send").click(function(){
        var VulnerabilitySelected = $("#SelectVulnerability option:selected").val();
        var IncidentSelected = $("#SelectIncident option:selected").val();
                $.ajax({
                    type: "POST",
                    data: "Type=3&Incident="+val+"&Vulnerability="+VulnerabilitySelected+"$Incident="+IncidentSelected,
                    url: "Contr_avi.jsp",
                    success: function(respuesta){                    
                    
                    }
                });
        
    });
                
            });
            function deleteincident(val){
                var VulnerabilitySelected = $("#SelectVulnerability option:selected").val();
                $.ajax({
                    type: "POST",
                    data: "Type=2&Incident="+val+"&Vulnerability="+VulnerabilitySelected,
                    url: "Contr_avi.jsp",
                    success: function(respuesta){                    
                    $("#Resultado").load("Contr_avi.jsp?Type=1&Vulnerability="+VulnerabilitySelected);
                    }
                });
            }
        </script>
        <section id="wrapper">
            <header>                
            </header>
            <jsp:include page="menu.jsp"></jsp:include>
            <p></p>
            <section id="container">
                <section id="FormType">                    
                    <form action="Contr_avi.jsp" method="post" name="VulnerabilityForm" id="VulnerabilityForm"> 
                        <input type="hidden" value="3" name="Type" />
                        <fieldset>
                            <h2> Asignar Incidentes a Vulnerabilidad</h2>
                            <table border="0" cellspacing="20">
                                <tr>
                                    <td><label for="SelectVulnerability">Vulnerabilidad:</label></td>
                                    <td>
                                        <select id="SelectVulnerability" name="SelectVulnerability">
                                        <%=Selects.FullVulnerability()%>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="SelectIncident">Incidentes</label></td>
                                <td>
                                    <select id="SelectIncident" name="SelectIncident">
                                        <%=Selects.FullIncident()%>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="Percentage">Porcentage:</label></td>
                                <td><input id="Percentage" name="Percentage" type="text" required="true" placeholder="Porcentaje del Incidente" maxlength="3" title="Ingrese un porcentaje válido."  pattern="^100$|^[0-9]{1,2}$|^[0-9]{1,2}\,[0-9]{1,3}$" /></td>
                            </tr>
                            <tr>
                                <td><input id="Send" name="Send" type="submit" class="button" value="Asignar Incidente"/></td>
                            </tr>
                        </table>
                        <section id="Resultado">
                        
                        </section>
                    </fieldset> 
                    </form>
                    
                </section>
            </section>
        </section>
        <footer>
            Proyecto de Investigacion de <a href="http://gitecx.unillanos.edu.co/" target="_blank">Gitecx</a> SAMP
        </footer>
    </body>
</html>